package cn.bigfire.compiler.dragon.appendixA.handwrite.inter;

import cn.bigfire.compiler.dragon.appendixA.handwrite.lexer.Num;
import cn.bigfire.compiler.dragon.appendixA.handwrite.lexer.Token;
import cn.bigfire.compiler.dragon.appendixA.handwrite.lexer.Word;
import cn.bigfire.compiler.dragon.appendixA.handwrite.symbols.Type;

public class Constant extends Expr {

    public Constant(Token token, Type type) {
        super(token, type);
    }

    public Constant(int i) {
        super(new Num(i), Type.Int);
    }

    //定义两个常量 true 和 false
    public static final Constant True = new Constant(Word.True,Type.Bool), False = new Constant(Word.False,Type.Bool);

    public void jumping(int t, int f) {
        if (this == True && t != 0) {
            emit("goto L" + t);
        } else if (this == False && t != 0) {
            emit("goto L" + f);
        }
    }

}
